package com.wt.springsamples;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;

/**
 * 1、AbstractApplicationContext # invokeBeanFactoryPostProcessors方法 ==>
 *   ConfigurationClassPostProcessor#processConfigBeanDefinitions方法
 *   =》ConfigurationClassParse#parse方法
 *   =》DeferredImportSelectorHandler#process方法
 *   =》DeferredImportSelectorGroupingHandler#processGroupImports方法（******关键步骤******）
 *   =》ConfigurationClassParse内部类DeferredImportSelectorGrouping#getImports方法
 *   => AutoConfigurationImportSelector内部类AutoConfigurationGroup的process方法
 *      执行meta-info/spring-factory.properties中自动配置内的解析
 *
 * 2、步骤1的DeferredImportSelectorGroupingHandler#processGroupImports方法=》
 * ConfigurationClassParser#processImports(ConfigurationClass configClass, SourceClass currentSourceClass,
 * 			Collection<SourceClass> importCandidates, Predicate<String> exclusionFilter,
 * 			boolean checkForCircularImports)方法
 * 执行如下代码：关键接口DeferredImportSelector
 * if (selector instanceof DeferredImportSelector) {
 * 	this.deferredImportSelectorHandler.handle(configClass, (DeferredImportSelector) selector);
 * }
 * else {
 * 	String[] importClassNames = selector.selectImports(currentSourceClass.getMetadata());
 * 	Collection<SourceClass> importSourceClasses = asSourceClasses(importClassNames, exclusionFilter);
 * 	processImports(configClass, currentSourceClass, importSourceClasses, exclusionFilter, false);
 * }
 */
//@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@SpringBootApplication
public class SpringSamplesApplication {

    public static void main(String[] args) {
        ApplicationContext applicationContext = SpringApplication.run(SpringSamplesApplication.class, args);
    }

//    @Bean
//    public UserDao userDao(){
//        return new UserDao();
//    }
//    private org.springframework.boot.web.servlet.ServletContextInitializer getSelfInitializer() {
//
//        return new ServletContextInitializer(){
//
//            @Override
//            public void onStartup(ServletContext servletContext) throws ServletException {
//                prepareWebApplicationContext(servletContext);
//                registerApplicationScope(servletContext);
//                WebApplicationContextUtils.registerEnvironmentBeans(getBeanFactory(), servletContext);
//                for (ServletContextInitializer beans : getServletContextInitializerBeans()) {
//                    beans.onStartup(servletContext);
//                }
//            }
//        };
//    }
}